<?php 
require_once 'init.php';
require_once 'ckLogin.php';
require_once 'dbClasses'.DIRECTORY_SEPARATOR.'config.php';
require_once 'dbClasses'.DIRECTORY_SEPARATOR.'dbConn.php';
$db = new dbConn();
//定义表名
define("TABLENAME","qutaobao_price9p9");
define("TABLENAME1","admin");
define("TABLENAME2","fanhuan_category");
//提交处理
if(strtoupper($_SERVER['REQUEST_METHOD'])=='POST'){
	$contentID=$_POST['contentID'];
	$title = $_POST['title'];
	$updater_2 = $_POST['updater_2'];
	$originalPrice = $_POST['originalPrice'];
	$currentPrice = $_POST['currentPrice'];
	$goodsUrl = $_POST['goodsUrl'];
	//
	$publishDate = $_POST['publishDate'];
	$sort = $_POST['sort'];
	$picture = $_POST['taobao_item_img'];
	$saledNum = $_POST['saledNum']?$_POST['saledNum']:0;
	$commission = $_POST['commission'];
	$pic_1 = $_POST["pic_1"];
	//手动录入用1，根据id接口用2，默认2
	$comefrom = $_POST['comefrom'];
	
	if(empty($contentID)){
		$db->sql="INSERT INTO `".TABLENAME."`(updater,goodsUrl,title,originalPrice,currentPrice,picture,publishDate,sort,comefrom) VALUES('".$updater_2."' , '".$goodsUrl."' , '".$title."' , '".$originalPrice."' , '".$currentPrice."' , '".$picture."' , '".$publishDate."' ,'".$sort."' , ".$comefrom.")";
		$db->doExecute();
?>
	<script type="text/javascript">
		this.location.replace('insertNew.php');
	</script>
<?php 
	}else{
		$db->sql="SELECT id,goodsID,updater,publishDate FROM `".TABLENAME."` WHERE  id = {$contentID} ";		
		$goodsInfo = $db->doResult2();
		if (empty($goodsInfo['goodsID'])) {
			die("商品id为空");
		}
		//判断15天内是否有其他人推荐该商品
		/* $db->sql="SELECT count(id) cid,IF( (publishDate>=DATE(DATE_SUB('{$publishDate}', INTERVAL 15 DAY)) AND (publishDate<='{$publishDate}') ) ,1,0) cLT,IF( (publishDate<=DATE(DATE_ADD('{$publishDate}', INTERVAL 15 DAY)) AND (publishDate>'{$publishDate}') ),1,0) cGT FROM content WHERE goodsID = {$goodsInfo['goodsID']} AND publishDate>=DATE(DATE_SUB('{$publishDate}', INTERVAL 15 DAY)) AND publishDate<=DATE(DATE_ADD('{$publishDate}', INTERVAL 15 DAY)) AND id != {$contentID} AND updater != '{$goodsInfo['updater']}' AND isDel!=1";
		$goodsInfoTongJi = $db->doResult2();
		//var_dump($goodsInfoTongJi);
		$noAccess=0;
		if ($goodsInfoTongJi['cid']>0) {
			if ($goodsInfoTongJi['cLT']>0) {
				$noAccess=1;
			}
			if ($goodsInfoTongJi['cGT']>0) {
				$noAccess=2;
			}
		} */
		/* //判断该商品是否已经被人录用了
		$db->sql="SELECT COUNT(c.id) FROM content c RIGHT JOIN admin a ON c.updater=a.userName AND a.isActive=1 WHERE c.publishDate >= '2013-04-01' AND c.goodsID = '{$goodsInfo['goodsID']}' AND c.updater != '{$goodsInfo['updater']}' UNION ".
			 	 "SELECT COUNT(c.id) num FROM priceninepointnine c RIGHT JOIN admin a ON c.updater=a.userName AND a.isActive=1 WHERE c.publishDate >= '2013-04-01' AND c.goodsID = '{$goodsInfo['goodsID']}' AND c.updater != '{$goodsInfo['updater']}'";
		$goodsInfoTongJi2 = $db->doResultList2();
		foreach ($goodsInfoTongJi2 as $i){
			//var_dump($i)
			$num+=$i['num'];
		}
		$noAccess2=0;
		if ($num>0) {
			$noAccess2=1;
		} */
		//if (strtotime($publishDate)>=strtotime(date("Y-m-d")) || strtotime($goodsInfo['publishDate'])==strtotime($publishDate)) {
			//if ($noAccess==0 && $noAccess2==0) {
				if ($comefrom==1 || $comefrom==2) {
					if($comefrom==1){
						$db->sql="UPDATE ".TABLENAME." SET updater = '".$updater_2."' , goodsUrl = '".$goodsUrl."' , title = '".$title."' , originalPrice = '".$originalPrice."' , currentPrice = '".$currentPrice."' , picture = '".$pic_1."' , publishDate = '".$publishDate."' , sort = ".$sort." , saledNum = ".$saledNum." , commission = ".$commission." WHERE id = ".$contentID;
						$db->doExecute();
					}elseif($comefrom==2){
						$db->sql="UPDATE ".TABLENAME." SET updater = '".$updater_2."' , goodsUrl = '".$goodsUrl."' , title = '".$title."' , originalPrice = '".$originalPrice."' , currentPrice = '".$currentPrice."' , picture = '".$pic_1."' , ";
						if(!empty($picture)){
							$db->sql .= "picture = '".$picture."' , ";
						}
						$db->sql .= "publishDate = '".$publishDate."' , sort = ".$sort." , saledNum = ".$saledNum." , commission = ".$commission." WHERE id = ".$contentID;
						//echo $db->sql;die();
						$db->doExecute();
					}
					//操作记录
					$db->sql = "INSERT INTO goodschange (changeid,`table`,goodsid,oldsaletime,operate,updater,changetime) VALUES({$contentID},'".TABLENAME."',{$goodsInfo['goodsID']},'{$goodsInfo["publishDate"]}','修改','{$_SESSION["userName"]}',".time().")";
					$db->doExecute();
				}else{
					die("失败的，没comefrom");
				}
				
			//}
		//}else{
		//	$publishDateError = true;
		//}
		$db->sql="SELECT `status` FROM `".TABLENAME."` WHERE id = ".$contentID;
		$status = $db->doResultOne();
		if($status==0){
			?>
				<script type="text/javascript">
				
					this.location.replace('qutaobao_insertNew.php?noaccess=<?php echo $noAccess;?>&publishDateError=<?php if($publishDateError) echo 1;?>');
				</script>
			<?php 
		}
	}
	
}
//条件
$where = "WHERE p.`status`!=0 AND p.`isDel`!=1 ";
if(!empty($_GET['startTime']) || !empty($_GET['endTime']) || !empty($_GET['updater']) || !empty($_GET['cateid']) || !empty($_GET['goodsid'])){
	if(!empty($_GET['startTime'])) $where.= "AND p.publishDate>='".$_GET['startTime']."' ";
	if(!empty($_GET['endTime'])) $where.= "AND p.publishDate<='".$_GET['endTime']."' ";
	if(!empty($_GET['updater'])) $where.= "AND p.updater='".$_GET['updater']."' ";
	if(!empty($_GET['cateid'])) $where.= "AND c.id='".$_GET['cateid']."' ";
	if(!empty($_GET['goodsid'])) $where.= "AND p.goodsID='".$_GET['goodsid']."' ";
	
}
//排序publishDate Updater shared collected
if(!empty($_GET['sort'])){
	$sortarray = explode('_', $_GET['sort']);
	$order = "p.".$sortarray[0]." ".$sortarray[1].",";
}else{
	$order = '';
}
//总条数
$db->sql="SELECT count(p.id) FROM ".TABLENAME." p LEFT JOIN ".TABLENAME2." c ON c.id = p.cateID ".$where;
$count= $db->doResultOne();
//分页
$page = $_GET['page'] ? $_GET['page'] : 1;
$pagesize = $_GET['pagesize']?$_GET['pagesize']:50;
$pageInfo = page($count, $pagesize, $page);
$maxPage = $pageInfo['maxPage'];
$start = $pageInfo['start'];
$pages = $pageInfo['pages'];

$db->sql="SELECT p.*,a.nickName,c.cate FROM ".TABLENAME." p LEFT JOIN ".TABLENAME1." a ON p.updater = a.userName LEFT JOIN ".TABLENAME2." c ON c.id = p.cateID ".$where." ORDER BY ".$order." p.publishDate DESC,p.sort ASC LIMIT ".$start.",".$pagesize;
$pictures = $db->doResultList2();
//ids
$ids='';
$db->sql="SELECT p.publishDate,GROUP_CONCAT(p.goodsID) ids FROM ".TABLENAME." p LEFT JOIN ".TABLENAME2." c ON c.id = p.cateID ".$where." GROUP BY publishDate";
$idsA = $db->doResultList2();
if (count($idsA)>0) {
	$ids = json_encode($idsA);
}
//分类
$db->sql="SELECT * FROM `".TABLENAME2."` ORDER BY `sort`";
$category = $db->doResultList2();
//var_dump($pictures);die();
//url
$url= "?startTime=".$_GET['startTime']."&endTime=".$_GET['endTime']."&updater=".$_GET['updater']."&pagesize=".$_GET['pagesize']."&goodsid=".$_GET['goodsid']."&cateid=".$_GET['cateid']."&sort=".$_GET['sort'];
$url2="?startTime=".$_GET['startTime']."&endTime=".$_GET['endTime']."&updater=".$_GET['updater']."&pagesize=".$_GET['pagesize']."&goodsid=".$_GET['goodsid']."&cateid=".$_GET['cateid'];
$url3="?startTime=".$_GET['startTime']."&endTime=".$_GET['endTime']."&updater=".$_GET['updater']."&pagesize=".$_GET['pagesize']."&goodsid=".$_GET['goodsid'];
$url4="?&updater=".$_GET['updater']."&pagesize=".$_GET['pagesize']."&goodsid=".$_GET['goodsid'];

$admins = getAdmin($db);
//今日商品数
$db->sql = "SELECT COUNT(id) FROM `".TABLENAME."` WHERE publishDate = date(now()) AND `status`=1 AND `isDel`!=1 ";
$todayGoodsNum = $db->doResultOne();
foreach ($category as $key => $item){
	$db->sql = "SELECT COUNT(id) FROM `".TABLENAME."` WHERE publishDate = date(now()) AND `status`=1 AND `isDel`!=1 AND `cateID` = {$item['id']}";
	$category[$key]['num'] = $db->doResultOne();
}
//var_dump($admins);
//用户列表
function getAdmin($db){
	$db->sql = "SELECT * FROM ".TABLENAME1." WHERE id != 1 AND type=2";
	return $admins = $db->doResultList2();
}
//分页
function page($total,$size,$page){
	//最大页数
	if($total%$size==0){
		$maxPage = $total/$size;
	}else{
		$maxPage = (int)($total/$size)+1;
	}
	//开始条数
	$start = ($page-1)*$size;
	//分页
	if($maxPage>=5){
		if($page<=2){
			$pages=array(1,2,3,4,5);
		}elseif($page>=($maxPage-1)){
			$pages=array($maxPage-4,$maxPage-3,$maxPage-2,$maxPage-1,$maxPage);
		}else{
			$pages=array($page-2,$page-1,$page,$page+1,$page+2);
		}
	}else{
		for($i=1;$i<=$maxPage;$i++){
			$pages[]=$i;
		}
	}
	if($page<=1){$previous=1;}else{$previous=$page-1;} 
	if($page>=$maxPage) {$next = $maxPage;}else{ $next = $page+1;}
	return array('maxPage'=>$maxPage,'start'=>$start,'pages'=>$pages,'previous'=>$previous,'next'=>$next);
}
//
function strcut($sourcestr,$cutlength)
{
    $returnstr='';
    $i=0;
    $n=0;
    $str_length=strlen($sourcestr);//字符串的字节数
    while (($n<$cutlength) and ($i<=$str_length))
    {
        $temp_str=substr($sourcestr,$i,1);
        $ascnum=Ord($temp_str);//得到字符串中第$i位字符的ascii码
        if ($ascnum>=224) //如果ASCII位高与224，
        {
            $returnstr=$returnstr.substr($sourcestr,$i,3);
            //根据UTF-8编码规范，将3个连续的字符计为单个字符
            $i=$i+3; //实际Byte计为3
            $n++; //字串长度计1
        }
        elseif ($ascnum>=192) //如果ASCII位高与192，
        {
            $returnstr=$returnstr.substr($sourcestr,$i,2);
            //根据UTF-8编码规范，将2个连续的字符计为单个字符
            $i=$i+2; //实际Byte计为2
            $n++; //字串长度计1
        }
        elseif ($ascnum>=65 && $ascnum<=90)
        //如果是大写字母，
        {
            $returnstr=$returnstr.substr($sourcestr,$i,1);
            $i=$i+1; //实际的Byte数仍计1个
            $n++; //但考虑整体美观，大写字母计成一个高位字符
        }
        else //其他情况下，包括小写字母和半角标点符号，
        {
            $returnstr=$returnstr.substr($sourcestr,$i,1);
            $i=$i+1; //实际的Byte数计1个
            $n=$n+0.5; //小写字母和半角标点等与半个高位字符宽…
        }
    }
    if ($str_length>$cutlength){
        $returnstr = $returnstr . "...";
        //超过长度时在尾处加上省略号
    }
    return $returnstr;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Simpla Admin</title>
<!--                       CSS                       -->
<!-- Reset Stylesheet -->
<link rel="stylesheet" href="resources/css/reset.css" type="text/css"
	media="screen" />
<!-- Main Stylesheet -->
<link rel="stylesheet" href="resources/css/main.css" type="text/css"
	media="screen" />
<!-- Invalid Stylesheet. This makes stuff look pretty. Remove it if you want the CSS completely valid -->
<link rel="stylesheet" href="resources/css/invalid.css" type="text/css"
	media="screen" />
<!-- Colour Schemes
		Default colour scheme is green. Uncomment prefered stylesheet to use it.
		<link rel="stylesheet" href="resources/css/blue.css" type="text/css" media="screen" />
		<link rel="stylesheet" href="resources/css/red.css" type="text/css" media="screen" />  
		-->
<!-- Internet Explorer Fixes Stylesheet -->
<!--[if lte IE 7]>
			<link rel="stylesheet" href="resources/css/ie.css" type="text/css" media="screen" />
		<![endif]-->
<!--                       Javascripts                       -->
<!-- jQuery -->
<script type="text/javascript" src="resources/scripts/jquery-1.7.2.min.js"></script>

<script type="text/javascript">

$(function($) {
	/* $.getJSON("http://42.96.169.153:5001/CountHandle.ashx?type=3&product_id=2,1&callback=?", function(data){
		//alert(data.Msg+data.Code);
		var obj = jQuery.parseJSON(data.Msg);
		$.each(obj, function(i,item){
			alert(item.Count);
		}); 
	}); */
	/* 
	$.ajax({
		   type: "GET",
		   url: "http://42.96.169.153:5001/CountHandle.ashx?type=3&product_id=2,1",
		   data: "",
		   dataType: "json",
		   success: function(data){
			   alert(data.Count);
			   
		   }
	});
	 */
	$(".issupergoods").change(function(){
		var id = $(this).parents("tr").data("id");
		//alert(goodsid);
		if($(this).is(":checked")) var val = 1; else var val = 0;
		$.ajax({
			type: "GET",
			url: "youpinAjax.php",
			data: "id="+id+"&act=changeother&table=qutaobao_price9p9&col=isSuperGoods&val="+val,
			dataType: "html",
			success: function(rs){
				if(rs==1) alert('修改成功 └(^o^)┘');
				else alert('修改失败 ╮(╯3╰)╭');
			}
		});
	});
	$(".isonlytoday").change(function(){
		var id = $(this).parents("tr").data("id");
		//alert(goodsid);
		if($(this).is(":checked")) var val = 1; else var val = 0;
		$.ajax({
			type: "GET",
			url: "youpinAjax.php",
			data: "id="+id+"&act=changeother&table=qutaobao_price9p9&col=isOnlyToday&val="+val,
			dataType: "html",
			success: function(rs){
				if(rs==1) alert('修改成功 └(^o^)┘');
				else alert('修改失败 ╮(╯3╰)╭');
			}
		});
	});
	$(".editbutton").click(function(){
		$("#pic_id").val($(this).attr('id'));
		//获取描述
		$.ajax({
			   type: "GET",
			   url: "getDesc.php?table=qutaobao_price9p9",
			   data: "id="+$(this).attr('id'),
			   dataType: "json",
			   success: function(date){
				   //alert( $("#cate_id2").val());
				   $("#description").html(date.desc);
				   $("#title").val(date.title);
				   $("#goodsUrl").val(date.goodsUrl);
				   $("#updater_2").val(date.updater);
				   $("#contentID").val(date.id);
				   $("#originalPrice").val(date.originalPrice); //
				   $("#currentPrice").val(date.currentPrice);
				   $("#comefrom").val(date.comefrom);
				   $("#sort").val(date.sort);
				   $("#publishDate").val(date.publishDate);
				   $("#updater_2 option").attr("selected",false);
				   $("#cate_id option").attr("selected",false);
				   $("#cate-option-"+date.cateID).attr("selected","selected");
				   $("#update-option-"+date.aid).attr("selected","selected");
				   $("#saledNum").val(date.saledNum);
				   $("#commission").val(date.commission);
				   $("#pic_1").val(date.picture);
				   $("#message_click").click();
			   }
		});
		
	});
	//删除商品
	$(".delbutton").click(function(){
		var id = $(this).data("id");
		//alert(id);return false;
		if(confirm("是否删除该商品！")){
			//获取描述
			$.ajax({
				type: "GET",
				url: "youpinAjax.php",
				data: "id="+id+"&act=del&table=qutaobao_price9p9",
				dataType: "html",
				success: function(date){
					//alert(date);
					
				}
			});
			$(this).parents("tr").hide();
			
		}
	});
	//商品上下架
	$(".isSalebutton").click(function(){
		var _this = $(this);
		var id = _this.data("id");
		var status = _this.data("status");
		if(status==1) {var word = "是否下架该商品？";}
		if(status==2) {var word = "是否上架该商品？";}
		//alert(id);return false;
		if(confirm(word)){
			$.ajax({
				type: "GET",
				url: "youpinAjax.php",
				data: "id="+id+"&act=isSale&table=qutaobao_price9p9",
				dataType: "html",
				success: function(rs){
					if(rs==1) {_this.text("上架中");alert("上架成功！！");};
					if(rs==2) {_this.text("下架中");alert("下架成功！！");};
					_this.data("status",rs);
				}
			});
		}
	});
	//多数据操作
	$(".xiugai").click(function(){
		//alert($("#caozuo option:selected").val());
			var text="";  
	        $("input[name=picSel]").each(function() {  
	            if ($(this).attr("checked")) {  
	                text += ","+$(this).val();  
	            }  
	        });
	        //alert(text);
	        window.location.replace('moreEdit.php?ids='+text);
		
	});
	//导出
	$("#download").click(function(){
		/* var startTime = $('#startTime').val();
		var endTime   = $('#endTime').val();
		var updater = $("#updater").val();
		//var pagesize = $("#pagesize").val();
		var cateid = $("#cateid").val();
	    
		$("input[name='starttime_d']").val(startTime);
		$("input[name='endtime_d']").val(endTime);
		$("input[name='cateid_d']").val(cateid);
		$("input[name='updater_d']").val(updater); */

		var ids = $("textarea[name='ids']").val();
		var totalnum = $("#totalNum").val();
		/* $.getJSON('http://42.96.169.153:5001/CountHandle.ashx?type=3&product_id='+ids+'&callback=?', function(data){
		    //alert(111);
			//alert(data.Msg+data.Code);
			var obj = jQuery.parseJSON(data.Msg);
			$("textarea[name='idsclick']").val(data.Msg);
			//$.each(obj, function(i,item){
			//	$("tr[goodsid='"+item.ProductId+"']").children(".clickNum").text(item.Count);
			//});
		}); */
		//alert(ids);
		var ii = 0;
		var idsjson = jQuery.parseJSON(ids);
		$.each( idsjson, function(i, n){
		    //alert( n.publishDate );
			$.getJSON("http://42.96.169.153:5001/CountHandle.ashx?type=3&product_id="+n.ids+"&starttime="+n.publishDate+"&callback=?", function(data){
				ii++;
				$("textarea[name='idsclick']").val($("textarea[name='idsclick']").val()+"___"+data.Msg);
				if(totalnum==ii) $("#formForDownload").submit();
			});
		});
		//$("#formForDownload").submit();
		
	});
	//批量删除
	$(".piliangshanchu").click(function(){
		if(confirm("是否删除这些商品！")){
			var ids='';
			$("input[name=picSel]:checked").each(function() {
				ids+=$(this).val()+',';
				$(this).parents("tr").remove();
			});
			$.ajax({
				type: "GET",
				url: "youpinAjax.php",
				data: "ids="+ids+"&act=piliangshanchu&table=qutaobao_price9p9",
				dataType: "html",
				success: function(date){
					//alert(date);
					
				}
			});
			//alert(ids);
		}
	});
});

</script>

<!-- jQuery Configuration -->
<script type="text/javascript" src="resources/scripts/simpla.jquery.configuration.js"></script>
<!-- Facebox jQuery Plugin -->
<script type="text/javascript" src="resources/scripts/facebox.js"></script>
<!-- jQuery WYSIWYG Plugin -->
<script type="text/javascript" src="resources/scripts/jquery.wysiwyg.js"></script>
<!-- jQuery my97datepicker -->
<script type="text/javascript" src="resources/scripts/My97DatePicker/WdatePicker.js"></script>
<!-- jQuery colorbox -->
<link rel="stylesheet" href="resources/css/colorbox.css" />
<script src="resources/scripts/colorbox/jquery.colorbox.js"></script>
<script type="text/javascript">
$(function($) {
	$(".group-pic").colorbox({rel:'group-pic',width:"50%", height:"75%"});
});
</script>
</head>
<body>
    <form action="downloadExcelForFH.php" method="post" id="formForDownload" style="display: none;">
        <input type="text" id="totalNum" value="<?php echo count($idsA);?>"/>
        <textarea name="ids"><?php echo $ids;?></textarea>
        <textarea name="idsclick"></textarea>
    </form>
	<div id="body-wrapper">
	<?php if ($noAccess==1 || $noAccess==2):?>
		<div class="notification error png_bg">
			<a href="#" class="close"><img src="resources/images/icons/cross_grey_small.png" title="Close this notification" alt="close" /></a>
			<div>
				修改失败，日期出错，该商品在这<span style="color: red;"><?php if ($noAccess==1) echo '之前';if ($noAccess==2) echo '之后';?></span>的15天已经上架。
			</div>
		</div>
	<?php endif;?>
	<?php if ($noAccess2==1):?>
		<div class="notification error png_bg">
			<a href="#" class="close"><img src="resources/images/icons/cross_grey_small.png" title="Close this notification" alt="close" /></a>
			<div>
				修改失败，已被其他责任编辑选用。
			</div>
		</div>
	<?php endif;?>
	<?php if ($publishDateError):?>
		<div class="notification error png_bg">
			<a href="#" class="close"><img src="resources/images/icons/cross_grey_small.png" title="Close this notification" alt="close" /></a>
			<div>
				修改失败，只能把时间改到今天或者之后，不能改到之前！
			</div>
		</div>
	<?php endif;?>
		<!-- Wrapper for the radial gradient background -->
		<a href="#messages" rel="modal" id="message_click"></a>
		<div id="messages" style="display: none;">
			<!-- Messages are shown when a link with these attributes are clicked: href="#messages" rel="modal"  -->

			<p style="">
				<strong>简短描述输入及修改</strong>
			</p>
			<form action="<?php echo $url."&page=".$page;?>" method="post">
				<fieldset>
					责任编辑：
					<select id="updater_2" name="updater_2" style="width: 300px;">
						<option value="" ></option>
						<?php foreach ($admins as $keyX=>$itemX):?>
						<option id="update-option-<?php echo $itemX['id'];?>" value="<?php echo $itemX['userName'];?>" <?php if($_SESSION['userName']==$itemX['userName']):?>selected="selected"<?php endif;?> ><?php echo $itemX['nickName'];?></option>
						<?php endforeach;?>
					</select><br />
					地址：
					<input class="text-input " type="text" id="goodsUrl" name="goodsUrl" style="width: 310px;"/><br />
					名称：
					<input class="text-input " type="text" id="title" name="title" style="width: 310px;"/><br />
					图片：
					<input class="text-input " type="text" id="pic_1" name="pic_1" style="width: 310px;"/><br />
					原价：
					<input class="text-input " type="text" id="originalPrice" name="originalPrice" style="width: 60px;"/>
					现价：
					<input class="text-input " type="text" id="currentPrice" name="currentPrice" style="width: 60px;"/>
					佣金：
					<input class="text-input " type="text" id="commission" name="commission" style="width: 60px;"/>%<br />
					发布日期：
					<input class="text-input " type="text" id="publishDate" name="publishDate" onClick="WdatePicker()"/><br />
					商品排序：
					<input class="text-input " type="text" id="sort" name="sort" value="1"/><br />
					已售数量：
					<input class="text-input " type="text" id="saledNum" name="saledNum" value=""/><br />
					<span id="taobao_img_span">
					</span>
					
					<input id="contentID" name="contentID" type="hidden" value="" />
					<input id="comefrom" name="comefrom" type="hidden" value="" />
					
					<input class="button" type="submit" value="修改" /> 
					<a href="javascript:void(0);" onclick="$(this).parents('#facebox').hide().siblings('#facebox_overlay').remove();">关闭</a>
				</fieldset>
			</form>
		</div>
		<!-- End #messages -->
		<div id="main-content">
			<!-- Main Content Section with everything -->
			<!-- Page Head -->
			<!-- <h2>欢迎使用<span style="color:red;">返还网商品</span>管理后台</h2> -->
			<!-- <p id="page-intro" style="color: red;">通告：从2013-04-01起，一个淘宝商品只能由一个责任编辑录用。之后其他人已不能添加</p>
			-->
			<div class="clear"></div>
			<!-- End .clear -->
			<div class="content-box">
				<!-- Start Content Box 
				<div class="content-box-header">
					<h3><?php echo WHAT;?>列表</h3>
					
					<div class="clear"></div>
				</div>-->
				<!-- End .content-box-header -->
				<div class="content-box-content">
				  <div>
				   <div style="padding: 10px;background-color: #E4E4E4;">
					<form method="get" action="" id="goodssearch">
						时间：
						<input class="text-input" type="text" id="startTime" name="startTime" onClick="WdatePicker()" value="<?php echo $_GET['startTime']?$_GET['startTime']:'';?>" size="10"/> 
						-
						<input class="text-input" type="text" id="endTime" name="endTime" onClick="WdatePicker()" value="<?php echo $_GET['endTime']?$_GET['endTime']:'';?>" size="10"/>
						&nbsp;&nbsp;&nbsp;责任编辑：
						<select id="updater" name="updater" style="">
							<option value="" ></option>
							<?php foreach ($admins as $keyX=>$itemX):?>
							<option id="" value="<?php echo $itemX['userName'];?>" <?php if($_GET['updater']==$itemX['userName']) echo 'selected="selected"';?>><?php echo $itemX['nickName'];?></option>
							<?php endforeach;?>
						</select>
						&nbsp;&nbsp;&nbsp;
						每页<input class="text-input" id="pagesize" name="pagesize" type="text" value="<?php echo $pagesize;?>" style="width: 25px;"/>条
						&nbsp;&nbsp;&nbsp;
						商品ID：<input class="text-input" type="text" id="goodsid" name="goodsid" value="<?php echo $_GET['goodsid'];?>" size="12"/>
						&nbsp;&nbsp;&nbsp; 
						<input type="hidden" id="cateid" name="cateid" value="<?php echo $_GET['cateid'];?>"/>
						<button class="button" id="zhixing" type="submit">搜索</button>
					</form>
				   </div>
					<!-- 
					今日上架<br />
					<a href="?startTime=<?php echo date("Y-m-d");?>&endTime=<?php echo date("Y-m-d");?>">全部</a>(<?php echo $todayGoodsNum;?>)
					<?php foreach ($category as $item):?>&nbsp;&nbsp;&nbsp;
						<?php if ($item['id']==$_GET['cateid']) : echo $item['cate'].'('.$item['num'].')';else:?>
						<a href="<?php echo $url4;?>&cateid=<?php echo $item['id'];?>&startTime=<?php echo date("Y-m-d");?>&endTime=<?php echo date("Y-m-d");?>"><?php echo $item['cate'].'('.$item['num'].')';?></a>
						<?php endif;endforeach;?> -->
				  </div>
					<div class="clear"></div>
					<div class="tab-content default-tab" id="tab1">
						<!-- This is the target div. id must match the href of this div's tab -->

						<table>
							<thead>
								<tr>
									<td colspan="18">
										<div class="bulk-actions align-left">
											<button class="button piliangshanchu" >批量删除</button>
										</div>
										<?php if($maxPage>0):?>
										<div class="pagination">
											<a href="<?php echo $url;?>&page=1" title="First Page">&laquo; First</a>
											<a href="<?php echo $url."&page=".$pageInfo['previous'];?>" title="Previous Page">&laquo; Previous</a>
											<?php foreach ($pages as $item):?> 
											<a href="<?php echo $url."&page=".$item;?>" class="number <?php if($item == $page) echo 'current';?>" title="<?php echo $item;?>"><?php echo $item;?></a>
											<?php endforeach;?>
											<a href="<?php echo $url."&page=".$pageInfo['next'];?>" title="Next Page">Next &raquo;</a>
											<a href="<?php echo $url."&page=".$maxPage;?>" title="Last Page">Last &raquo;</a>
											total : <?php echo $maxPage;?>
										</div> 
										<?php endif;?>
										<!-- End .pagination -->
										<hr class="clear" />
									</td>
								</tr>
							</thead>
							<thead>
								<tr >
									<th><input class="check-all" type="checkbox" value="-1"/></th>
									<th style="display: none;">编号</th>
									<th style="width: 80px;" class="taobao_url_css">商品ID</th>
									<th style="width: 50px;">图片</th>
									
									<th style="">标题</th>
									<th style="width: 40px;">原价</th>
									<th style="width: 40px;">现价</th>
									<th style="width: 40px;">已售</th>
									<th style="width: 50px;">佣金</th>
									<th style="width: 70px;">
										日期<br /><span ><a href="<?php echo $url2;?>&sort=publishDate_asc">
											<?php if($_GET['sort'] == "publishDate_asc"):?><img src="resources/images/sort3.png" />
											<?php else:?><img src="resources/images/sort1.png" /><?php endif;?>
											</a>
											<a href="<?php echo $url2;?>&sort=publishDate_desc">
											<?php if($_GET['sort'] == "publishDate_desc"):?><img src="resources/images/sort4.png" />
											<?php else:?><img src="resources/images/sort2.png" /><?php endif;?>
											</a>
										</span>
									</th>
									
									<th style="width: 15px;">排序</th>
									<th style="width: 30px;">点击</th>
									
									<th style="width: 40px;">责任<br />编辑<br /><span ><a href="<?php echo $url2;?>&sort=updater_asc">
											<?php if($_GET['sort'] == "updater_asc"):?><img src="resources/images/sort3.png" />
											<?php else:?><img src="resources/images/sort1.png" /><?php endif;?>
											</a>
											<a href="<?php echo $url2;?>&sort=updater_desc">
											<?php if($_GET['sort'] == "updater_desc"):?><img src="resources/images/sort4.png" />
											<?php else:?><img src="resources/images/sort2.png" /><?php endif;?>
											</a>
									</span></th>
									
									<th style="width: 40px;">操作</th>
								</tr>

							</thead>

							<tbody>
							<?php if(count($pictures)>0):?>
							<?php foreach ($pictures as $key=>$item):$goodsIDs.=$item['goodsID'].',';?>
								<tr goodsid="<?php echo $item['goodsID'];?>" data-id="<?php echo $item['id'];?>">
									<td ><input type="checkbox" name="picSel" value="<?php echo $item['id'];?>"/></td>
									<td style="display: none;"><?php echo $item['id'];?></td>
									<td><a href="<?php echo $item['goodsUrl'];?>" target="_blank"><?php echo $item['goodsID'];?></a></td>
									<td>
										<p><a class="group-pic" href="<?php echo $item['picture'];?>">
											<img src="<?php echo $item['picture'];?>" onerror="this.src='<?php $item['picture'];?>'" alt="" width="50px;" height="50px;"/>
										</a></p>
									</td>
									<td title=""><?php echo $item['title'];?></td>
									<td><?php echo $item['originalPrice'];?></td>
									<td><?php echo $item['currentPrice'];?></td>
									<td><?php echo $item['saledNum'];?></td>
									<td><?php if(!empty($item['commission'])) echo '<span>'.$item['commission'].'</span>%';?></td>
									<td><?php echo $item['publishDate'];?></td>
									<td><?php echo $item['sort'];?></td>
									<td class="clickNum"><?php echo $item['clickNum'];?></td>
									
									<td><?php echo isset($item['nickName'])?$item['nickName']:$item['updater'];?></td>
									<td>
										<!-- Icons --> 
										<a  title="Edit" class="editbutton" id="<?php echo $item['id'];?>" style="cursor: pointer;">修改</a> <br /><br />
										<a  title="Del" class="delbutton" data-id="<?php echo $item['id'];?>" style="cursor: pointer;">删除</a><br /><br />
										<a  title="Sale" class="isSalebutton" data-id="<?php echo $item['id'];?>" data-status=<?php echo $item['status'];?> style="cursor: pointer;<?php if($item['status']==2) echo 'color: black;';?>"><?php if($item['status']==1) echo '上架中';if($item['status']==2) echo '下架中';?></a>
										<!-- <a href="#" title="Edit Meta"><img src="resources/images/icons/hammer_screwdriver.png" alt="Edit Meta" /></a> -->
									</td>
								</tr>
							<?php endforeach;?>
							<?php else:?>
								<tr style="font-size: 50px;text-align: center; font-weight: bold;"><td colspan="9" style="text-align: center;">没有<?php echo WHAT;?></td></tr>
							<?php endif;?>
							</tbody>
							<tfoot>
								<tr>
									<td colspan="18">
										<div class="bulk-actions align-left">
											<button class="button piliangshanchu" >批量删除</button>
										</div>
										<?php if($maxPage>0):?>
										<div class="pagination">
											<a href="<?php echo $url;?>&page=1" title="First Page">&laquo; First</a>
											<a href="<?php echo $url."&page=".$pageInfo['previous'];?>" title="Previous Page">&laquo; Previous</a>
											<?php foreach ($pages as $item):?> 
											<a href="<?php echo $url."&page=".$item;?>" class="number <?php if($item == $page) echo 'current';?>" title="<?php echo $item;?>"><?php echo $item;?></a>
											<?php endforeach;?>
											<a href="<?php echo $url."&page=".$pageInfo['next'];?>" title="Next Page">Next &raquo;</a>
											<a href="<?php echo $url."&page=".$maxPage;?>" title="Last Page">Last &raquo;</a>
											total : <?php echo $maxPage;?>
										</div>
										<?php endif;?>
										<!-- End .pagination -->
										<div class="clear"></div>
									</td>
								</tr>
							</tfoot>

						</table>

					</div>
					<!-- End #tab1 -->


				</div>
				<!-- End .content-box-content -->

			</div>
			<!-- End .content-box -->

			<div class="clear"></div>

			<div id="footer">
				<small> <!-- Remove this notice or replace it with whatever you want -->
					&#169; Copyright 2009 Your Company | Powered by 
					<a href="http://themeforest.net/item/simpla-admin-flexible-user-friendly-admin-skin/46073">Simpla Admin</a> | <a href="#">Top</a>
				</small>
			</div>
			<!-- End #footer -->

		</div>
		<!-- End #main-content -->

	</div>
	<?php echo 'http://42.96.169.153:5001/CountHandle.ashx?type=3&product_id='.rtrim($goodsIDs,',').'&starttime='.$_GET['startTime'].'&callback=?';?>
<script type="text/javascript">
/* $(function($) {
	$.getJSON("<?php //echo 'http://42.96.169.153:5001/CountHandle.ashx?type=3&product_id='.rtrim($goodsIDs,',').'&starttime='.$_GET['startTime'].'&callback=?';?>", function(data){
		//alert(data.Msg+data.Code);
		var obj = jQuery.parseJSON(data.Msg);
		$.each(obj, function(i,item){
			$("tr[goodsid='"+item.ProductId+"']").children(".clickNum").text(item.Count);
		});
	});
});
 */
</script>
</body>
<!-- Download From www.exet.tk-->
</html>
